package com.job.client.city.factory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
 
public class ConnectionFactory  {
    private static Connection connection = null;
    public static Connection getDatabaseConnection() {
        try {
            if (connection == null || connection.isClosed()) {
                synchronized (ConnectionFactory.class) {
                    if (connection == null || connection.isClosed()) {
                        // 修改为需要存储的目标数据库配置，也可以考虑使用连接池等提高可用性及效率
                        connection = DriverManager.getConnection("jdbc:mysql://121.40.171.110:3306/job-log-service", "root", "1234");
                    }
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }
}